package com.example.base;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @Title: TestMap
 * @Description: TODO
 * @Date 2022/1/10 18:05
 */
public class TestMap {
    public static void main(String[] args) {


        Map<String, Long> map = new HashMap<>();
        map.put("aaa1", 2L);
        System.out.println(map);
        //不存在，进行操作
        map.putIfAbsent("aaa1", 1L);
        //不存在，且value不为空，进行操作
        map.computeIfAbsent("aaa12", s -> null);
        System.out.println(map);
        //存在，且value不为空，进行操作,value为空，删除key
        map.computeIfPresent("aaa1", (s, aLong) -> 3L + aLong);
        System.out.println(map);

        new Thread(() -> System.out.println("xxxx-->" + Thread.currentThread().getName()), "1111111111xxxxxx").start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("111111");
            }
        }).start();
        System.out.println(map);
        
        File file = null;
        file.delete();

    }
}
